package main

import "fmt"

func main() {

	fmt.Println("Sum of multiples of 3 and 5 = ",
		sumOfMultiples(3, 1000)+sumOfMultiples(5, 1000)-sumOfMultiples(15, 1000))

}

func sumOfMultiples(factor, limit int) int {

	if factor <= 0 {
		return 0
	}

	sum := 0
	for i := 1; i < limit; i++ {
		if i%factor == 0 {
			sum += i
		}
	}

	return sum
}
